From b43cd27790af7c9f0d22a60fc634645d5714b981 Mon Sep 17 00:00:00 2001 From: Raimond Spekking Date: Wed, 18 Jul 2007 16:04:49 +0000 Subject: [PATCH] * (bug 10631) Warn when illegal characters are removed from filename at upload Probably a regression, I am sure I have seen this warning in the past --- RELEASE-NOTES | 2 +- includes/SpecialUpload.php | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 1bd5f40626..66834b4ef9 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -315,7 +315,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 10615) Fix for transwiki import when CURL not available * (bug 8054) Return search page for empty search requests with ugly URLs * (bug 10572) Force refresh after clearing visitation timestamps on watchlist - +* (bug 10631) Warn when illegal characters are removed from filename at upload == API changes since 1.10 == diff --git a/includes/SpecialUpload.php b/includes/SpecialUpload.php index 9394108960..83b3811350 100644 --- a/includes/SpecialUpload.php +++ b/includes/SpecialUpload.php @@ -284,16 +284,17 @@ class UploadForm { # Chop off any directories in the given filename if( $this->mDesiredDestName ) { - $basename = wfBaseName( $this->mDesiredDestName ); + $basename = $this->mDesiredDestName; } else { - $basename = wfBaseName( $this->mSrcName ); + $basename = $this->mSrcName; } + $filtered = wfBaseName( $basename ); /** * We'll want to blacklist against *any* 'extension', and use * only the final one for the whitelist. */ - list( $partname, $ext ) = $this->splitExtensions( $basename ); + list( $partname, $ext ) = $this->splitExtensions( $filtered ); if( count( $ext ) ) { $finalExt = $ext[count( $ext ) - 1]; @@ -317,7 +318,7 @@ class UploadForm { * Filter out illegal characters, and try to make a legible name * out of it. We'll strip some silently that Title would die on. */ - $filtered = preg_replace ( "/[^".Title::legalChars()."]|:/", '-', $basename ); + $filtered = preg_replace ( "/[^".Title::legalChars()."]|:/", '-', $filtered ); $nt = Title::makeTitleSafe( NS_IMAGE, $filtered ); if( is_null( $nt ) ) { $this->uploadError( wfMsgWikiHtml( 'illegalfilename', htmlspecialchars( $filtered ) ) ); @@ -388,7 +389,7 @@ class UploadForm { if( $wgCapitalLinks ) { $filtered = ucfirst( $filtered ); } - if( $this->mDestName != $filtered ) { + if( $basename != $filtered ) { $warning .= '
  • '.wfMsgHtml( 'badfilename', htmlspecialchars( $this->mDestName ) ).'
  • '; } -- 2.20.1